/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newstuff;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Tich
 */
public class ServerThread implements Runnable {

    private ServerSocket socket;
    private SocketAddress address;
    private Socket clientSocket;
    private ServerDetails details;
    
    public ServerThread(SocketAddress address)
    {
        this.address = address;
    }
    
    @Override
    public void run() {
        try {
            socket = new ServerSocket(5555);
            socket.bind(address);
            socket.setSoTimeout(10000);
            String ip = ((InetSocketAddress)socket.getLocalSocketAddress()).getHostString();
            int port = socket.getLocalPort();
            while(true)
            {
                try{
                    clientSocket = socket.accept();
                    BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                    
                }
                catch (SocketTimeoutException ex)
                {
            
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(ServerThread.class.getName()).log(Level.SEVERE, null, ex);
        } 
        finally{
            try {
                socket.close();
            } catch (IOException ex) {
                Logger.getLogger(ServerThread.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
}
